<template>
	<view>
		<view class="bg">
			这是传递过来的参数，商品Id ：{{goodsId}}
		</view>

		<view class="">
			商品名：{{goods.name}}
		</view>
		<view class="">
			商品规格：{{goods.spec}}
		</view>

	</view>
</template>

<script>
	export default {
		data() {
			return {
				goodsId: null,
				goods: {},
			}
		},
		onLoad(options) {
			this.goodsId = parseInt(options.goodsId) || 0
			this.loadData();
		},

		methods: {
			loadData() {
				uni.showLoading({
					title: 'loading'
				});
				uni.request({
					url: 'http://www.zjff495.cn:5058/app/v1/goods/' + this.goodsId
				}).then(result => {
					uni.hideLoading();
					console.log(result.data);
					this.goods = result.data.data;
				}).catch(error => {
					console.log(error)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.bg {
		height: 200px;
		background-color: $uni-bg-color-grey;
	}
</style>